package com.zsw.recongize.parse;

//import java.io.File;
import java.io.IOException;

//import com.itextpdf.awt.geom.Rectangle2D;
//import com.itextpdf.text.Rectangle;
//import com.itextpdf.text.pdf.PdfReader;
//import com.itextpdf.text.pdf.parser.FilteredTextRenderListener;
//import com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy;
//import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
//import com.itextpdf.text.pdf.parser.PdfTextExtractor;
//import com.itextpdf.text.pdf.parser.RegionTextRenderFilter;
//import com.itextpdf.text.pdf.parser.RenderFilter;
//import com.itextpdf.text.pdf.parser.SimpleTextExtractionStrategy;
//import com.itextpdf.text.pdf.parser.TextExtractionStrategy;

public class ITextParse {
	
	public static void main(String[] args) throws IOException {
//		File f = new File("D://invoice/files/5月27日洗衣服发票88071858.pdf");
//		PdfReader reader = new PdfReader(f.getAbsolutePath()); //抽取文件
////		PdfReaderContentParser parser = new PdfReaderContentParser(reader);
//		Rectangle size = reader.getPageSize(1);
//		Rectangle2D rect = new com.itextpdf.awt.geom.Rectangle2D.Float(430, size.getHeight() - 90, 500, 90);
//		RenderFilter[] a = {new RegionTextRenderFilter(rect)}; 
//		FilteredTextRenderListener strategy = new FilteredTextRenderListener(new LocationTextExtractionStrategy(), a);
//		System.out.println(PdfTextExtractor.getTextFromPage(reader, 1,strategy));//输出
		
//		System.out.println(PdfTextExtractor.getTextFromPage(reader, 1));
//		System.out.println(ITextParse.getPdfFileText(reader));
	}

//	public static String getPdfFileText(PdfReader reader) throws IOException {
//			PdfReaderContentParser parser = new PdfReaderContentParser(reader);
//			StringBuffer buff = new StringBuffer();
//			TextExtractionStrategy strategy;
//			for (int i = 1; i <= reader.getNumberOfPages(); i++) {
//				
//				strategy = parser.processContent(i,new SimpleTextExtractionStrategy());
//				buff.append(strategy.getResultantText());
//			}
//			return buff.toString();
//		}

}
